#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("tree.in" , "r" , stdin);
	freopen("tree.out" , "w" , stdout);
	int a[10010] , L , M;
	cin >> L >> M;
	int i = 0;
	while(i <= L){
		a[i] = 1;
		i = i + 1;
	}
	for(int j = 1 ; j <= M ; j++){
		int l ,r;
		cin >> l >> r;
		for(int n = l ; n <= r ; n ++){
			a[n] = 0;
		}
	}
	int k = 0 , t = 0;
	while(k <= L){
		if(a[k] == 1){
			t = t + 1;
		}
		k = k + 1;
	}
	cout << t << endl;
	return 0;
}